<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0.maximum-scale=1.0,user-scalable=no" name="viewport">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/homePage.css">
    <link rel="stylesheet" href="css/flexible.css">
    <link rel="stylesheet" href="css/vant.css">
    <script src="js/jquery-3.3.1.min.js"></script>
    <script src="js/flexible.js"></script>
    <script src="js/vue.js"></script>
    <script src="js/axios.js"></script>
    <script src="js/MD5.js"></script>
    <script src="js/qs.js"></script>
    <script src="js/vant.js"></script>
</head>
<body>
<div class="container_box" id="app">
  <div class="Information_entry">
      <label class="lf">原密码</label>
      <div class="rf message padding14">
          <input v-model="from.Oldpassword" placeholder="请输入原始密码">
      </div>
  </div>
    <div class="Information_entry">
        <label class="lf">新密码</label>
        <div class="rf message padding14">
            <input v-model="from.Password" type="number" placeholder="请输入新密码">
        </div>
    </div>
    <div class="Information_entry">
        <label class="lf">确认密码</label>
        <div class="rf message padding14">
            <input v-model="from.Conpassword" type="number" placeholder="请再次输入新密码">
        </div>
    </div>
    <div class="save">
        <button type="button" @click="edit">提交</button>
    </div>
</div>
</body>
<script>
    new Vue({
        el: '#app',
        data: {
           from:{
            Oldpassword: "",
            Password: "",
            Conpassword: ""
           }
        },
        methods:{
            //修改密码
            edit(){
                if (this.from.Password != this.from.Conpassword) {
                    window.vant.Toast.fail('两次密码输入不一样');
                    return;
                }


                getVs()
                sessionStorage.setItem('logo','0')
                //console.log(this.from)
                let Oldpassword=md5(this.from.Oldpassword)
                Oldpassword=md5(Oldpassword)
                let Password=md5(this.from.Password)
                Password=md5(Password)
                let Conpassword=md5(this.from.Conpassword)
                Conpassword=md5(Conpassword)
                let from = {
                     Oldpassword: Oldpassword,
                     Password: Password,
                     Conpassword:Conpassword
                }
                from =JSON.stringify(from)
                console.log(from)
                let sign=md5(from)
                const params={
                    from:from,
                    sign:sign
                }
                axios.post('/mobileapi/adviser/user.php?act=set_password',Qs.stringify(params)).then(data =>{
                    console.log(data.data)
                    let { msg, code,user} = data.data
                        if (code !== 200) {
                            window.vant.Toast.fail('密码修改失败')
                        } else {
                            window.vant.Toast.success('密码修改成功')
                            this.timer = setTimeout(this.list, 2000);
                        }
                    }).catch(function (error) {
                        console.log(error); 
                });
            },
            list(){
                window.location.href='login.html?vid='
            }
        }
    })
</script>
</html>